package com.ruoyi.module.privateaccount.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.module.privateaccount.domain.BizPrivateAccount;
import com.ruoyi.module.privateaccount.service.IBizPrivateAccountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 个人账户Controller
 * 
 * @author zhaoxi
 * @date 2023-09-08
 */
@RestController
@RequestMapping("/module/privateaccount")
public class BizPrivateAccountController extends BaseController
{
    @Autowired
    private IBizPrivateAccountService bizPrivateAccountService;

    /**
     * 查询个人账户列表
     */
    @PreAuthorize("@ss.hasPermi('module:privateaccount:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizPrivateAccount bizPrivateAccount)
    {
        startPage();
        List<BizPrivateAccount> list = bizPrivateAccountService.selectBizPrivateAccountList(bizPrivateAccount);
        return getDataTable(list);
    }

    /**
     * 导出个人账户列表
     */
    @PreAuthorize("@ss.hasPermi('module:privateaccount:export')")
    @Log(title = "个人账户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizPrivateAccount bizPrivateAccount)
    {
        List<BizPrivateAccount> list = bizPrivateAccountService.selectBizPrivateAccountList(bizPrivateAccount);
        ExcelUtil<BizPrivateAccount> util = new ExcelUtil<BizPrivateAccount>(BizPrivateAccount.class);
        return util.exportExcel(list, "个人账户数据");
    }

    /**
     * 获取个人账户详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:privateaccount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bizPrivateAccountService.selectBizPrivateAccountById(id));
    }

    /**
     * 新增个人账户
     */
    @PreAuthorize("@ss.hasPermi('module:privateaccount:add')")
    @Log(title = "个人账户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizPrivateAccount bizPrivateAccount)
    {
        return toAjax(bizPrivateAccountService.insertBizPrivateAccount(bizPrivateAccount));
    }

    /**
     * 修改个人账户
     */
    @PreAuthorize("@ss.hasPermi('module:privateaccount:edit')")
    @Log(title = "个人账户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizPrivateAccount bizPrivateAccount)
    {
        return toAjax(bizPrivateAccountService.updateBizPrivateAccount(bizPrivateAccount));
    }

    /**
     * 删除个人账户
     */
    @PreAuthorize("@ss.hasPermi('module:privateaccount:remove')")
    @Log(title = "个人账户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizPrivateAccountService.deleteBizPrivateAccountByIds(ids));
    }
}
